﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using MpSoft.Library.BUSS.Settings; 

namespace MpSoft.Web.AdminCP.Controls.Configs
{
    public partial class SetBanner : System.Web.UI.UserControl
    {
        #region Method

        private void BindControl()
        {
            txtFile.Text = SettingBUSS.GetSettingValue("banner.file");
            txtLink.Text = SettingBUSS.GetSettingValue("banner.link");
            txtWidth.Text = SettingBUSS.GetSettingValue("banner.width");
            txtHeight.Text = SettingBUSS.GetSettingValue("banner.height");
        }

        public int Save()
        {
            var banner = SettingBUSS.Setting_ByKey("banner.File");
            // Image, Flash
            banner.SettingValue = txtFile.Text;
            banner.SettingGroup = "banner";
            SettingBUSS.Setting_Update(banner);
            //Link 
            banner = SettingBUSS.Setting_ByKey("banner.link");
            banner.SettingValue = txtLink.Text;
            banner.SettingGroup = "banner";
            SettingBUSS.Setting_Update(banner);
            //Width
            banner = SettingBUSS.Setting_ByKey("banner.width");
            banner.SettingValue = txtWidth.Text;
            banner.SettingGroup = "banner";
            SettingBUSS.Setting_Update(banner);
            //Height
            banner = SettingBUSS.Setting_ByKey("banner.height");
            banner.SettingValue = txtHeight.Text;
            banner.SettingGroup = "banner";
            SettingBUSS.Setting_Update(banner);
            return 1;
        }

        #endregion

        #region Event
        
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
                BindControl();
        }

        #endregion
    }
}